package warmachineroster.presentation;

import org.eclipse.gef.palette.CreationToolEntry;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.PaletteToolbar;
import org.eclipse.gef.palette.PanningSelectionToolEntry;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gef.requests.CreationFactory;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import warmachineroster.RosterElement;
import warmachineroster.WarmachinerosterPackage;

public class WarmachineEditorPaletteFactory {

	public static PaletteRoot createPalette(){
		PaletteRoot palette = new PaletteRoot();
		palette.add(createToolsGroup(palette));
		return palette;
	}
	
	private static PaletteContainer createToolsGroup(PaletteRoot palette) {
		PaletteToolbar toolbar = new PaletteToolbar("Tools");

		// Add a selection tool to the group
		ToolEntry tool = new PanningSelectionToolEntry();
		toolbar.add(tool);
		palette.setDefaultEntry(tool);
		

		CreationToolEntry reEntry = new CreationToolEntry("New RosterElement", "Create a new rosterElement",
				 new CreationFactory(){

					@Override
					public Object getNewObject() {
						
						return WarmachinerosterPackage.eINSTANCE.getWarmachinerosterFactory().createRosterElement();
					}

					@Override
					public Object getObjectType() {
						// TODO Auto-generated method stub
						return RosterElement.class;
					}
					}, 
					AbstractUIPlugin.imageDescriptorFromPlugin(
							"WarmaBuilder.editor", "icons/full/obj16/WarmachinerosterModelFile.gif")
					, null);
		
		toolbar.add(reEntry);
		return toolbar;
	}
}
